package com.byt.framlib.commonutils.notifycation;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import androidx.core.app.NotificationCompat;

/**
 * 默认的 NotificationBuilder
 */
public class BasicNotificationBuilder implements NotificationInterface {

    private Context mContext ;
    private GetPendingIntent mCallback;
    private Class mclassT;

    public BasicNotificationBuilder(Context context , GetPendingIntent callback,Class classT){
        mContext = context ;
        mCallback = callback ;
        this.mclassT = classT;
    }

    /**
     * 创建一个默认的NotificationBuilder
     * 设置3个必填参数.setSmallIcon(iconId)
     *		     .setContentTitle(title)
     *			 .setContentText(content)
     */
    @Override
    public NotificationCompat.Builder generateNotifacationBuilder(String title, String content, int iconId) {
        NotificationCompat.Builder builder =
                new NotificationCompat.Builder(mContext)
                        .setSmallIcon(iconId)
                        .setContentTitle(title)
                        .setContentText(content)
                        .setAutoCancel(true)
                        .setDefaults(Notification.DEFAULT_ALL)
                        .setContentIntent(mCallback.getPendingIntent(mclassT)) ;

        return builder;
    }
    /**
     *
     * @ClassName: GetPendingIntent
     * @Description: 回调接口，获取具体的PendingIntent以解决用户点击back键时返回到哪个界面的问题
     * 				根据不同的需求可以在getPendingIntent函数的实现中设置不同的PendingIntent
     */
    public interface GetPendingIntent{
        public PendingIntent getPendingIntent(Class classT) ;
    }

}
